%run ./data/data.ipynb
Pulling data from sources.json: (Source: CBS) deceased @ https://opendata.cbs.nl/statline/portal.html?_catalog=CBS&_la=nl&tableId=70895ned&_theme=76 (Source: CBS) population @ https://opendata.cbs.nl/statline/portal.html?_catalog=CBS&_la=nl&tableId=37230ned&_theme=76 (Source: RIVM) counts_per_municipality @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/5f6bc429-1596-490e-8618-1ed8fd768427 (Source: RIVM) prevalence @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/097155aa-75eb-4caa-8ed3-4c6edb80467e (Source: RIVM) r @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/ed0699d1-c9d5-4436-8517-27eb993eab6e (Source: RIVM) homes_for_elderly @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/0179dd26-7bf6-4021-857f-8623aaf8e73a (Source: RIVM) homes_for_disabled @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/aa28b74d-7150-47bc-a7cb-98876e93381b (Source: RIVM) seventy_plus_living_at_home @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/40508e17-7296-4f39-ad25-8ddd0c904087 (Source: RIVM) sewage @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/a2960b68-9d3f-4dc3-9485-600570cd52b9 (Source: RIVM) support_and_behavior @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/8a72d78a-fcf8-4882-b0ab-cd594961a267?tab=relations (Source: RIVM) wekelijkse_update @ https://www.rivm.nl/coronavirus-covid-19/actueel/wekelijkse-update-epidemiologische-situatie-covid-19-in-nederland (Source: NICE) hospital_admission @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/4f4ad069-8f24-4fe8-b2a7-533ef27a899f (Source: NICE) ic_admission @ https://data.rivm.nl/geonetwork/srv/dut/catalog.search#/metadata/45f911c4-3a62-42f1-b594-524a75db2c94 (Source: LCPS) hospital_occupation @ https://lcps.nu/datafeed/ (Source: Nivel) general_practioner @ https://www.nivel.nl/nl/nivel-zorgregistraties-eerste-lijn/monitor-cijfers-covid-19-achtige-klachten-huisartsenpraktijken#opendata Creating dataframes for analysis: dataframe from cbs created, per week per agegroup: deceased_week_agegroup dataframe from cbs created, per week: deceased_per_week dataframe from cbs created, per year per agegroup: deceased_year_agegroup dataframe from cbs created, per year: deceased_per_year dataframe from cbs created, per month per municipality: population_month_municipality dataframe from cbs created, per year per municipality: population_year_municipality dataframe from cbs created, per month: population_per_month dataframe from cbs created, per month: population_per_year dataframe for RIVM data created, per day: rivm_per_day dataframe for RIVM data created: rivm_per_week dataframe for RIVM data created, per month: rivm_per_month dataframe for RIVM data created, per month: rivm_per_year dataframe from cbs created, per week per agegroup: rivm_week_agegroup dataframe CBS and RIVM combined, per week: per_week dataframe CBS and RIVM combined, per month: per_month dataframe CBS and RIVM combined, per month: per_year
import os
import sys
import click
import numpy as np
import seaborn as sns
import datetime
from SEIR.seir import SEIR
from SEIR.visualization import visualize_seir_computation
from matplotlib import rcParams
rcParams['figure.figsize'] = 20,10
visualize_compartments = False
output_file_format = 'csv'
#output_file_format = 'json'
output_file = './data/csvs/seir.'+output_file_format
# Define model
def run_model(action=None):
model = SEIR(
incubation_period=incubation_period,
infectious_period=infectious_period,
initial_R0=initial_R0,
hospitalization_probability=hospitalization_probability,
hospitalization_duration=hospitalization_duration,
hospitalization_lag_from_onset=hospitalization_lag_from_onset,
icu_probability=icu_probability,
icu_duration=icu_duration,
icu_lag_from_onset=icu_lag_from_onset,
death_probability=death_probability,
death_lag_from_onset=death_lag_from_onset,
population=population,
compartments = compartments,
contacts_matrix = contacts_matrix,
restrictions_function = restrictions_function,
imported_cases_function = imported_cases_function
)
model.set_initial_state(
population_exposed = population_exposed,
population_infected = population_infected,
probabilities = probabilities
)
model.simulate(
max_simulation_time = max_simulation_time,
method = method,
max_step = max_step
)
# Evaluate the solution
time = np.arange(0, max_simulation_time, 1, dtype=int)
global results
results = model.evaluate_solution(time)
# Visualize the results
if action == 'show':
visualize_seir_computation(
results,
compartments=compartments,
restrictions_info=restr_info,
show_individual_compartments=visualize_compartments
)
elif action == 'save':
if output_file_format == 'csv':
results.to_csv(output_file)
elif output_file_format == 'json':
results.to_json(output_file)
else:
return results
# test settings
incubation_period = 3
infectious_period = 7
initial_R0 = 1
hospitalization_probability = 0.1
hospitalization_duration = 20
hospitalization_lag_from_onset = 7
icu_probability = 0.01
icu_duration = 10
icu_lag_from_onset = 11
death_probability = 0.1
death_lag_from_onset = 25
population = 17e6
compartments = None #Optional[List[Any]]
contacts_matrix = None # Optional[numpy.ndarray]
restrictions_function = None # Optional[Callable[[float], Union[float, numpy.ndarray]]]
imported_cases_function = None # Optional[Callable]
restr_info = ''
#[restriction everyone-begin-careful]
#day-begins = 20
#day-ends = 180
#infectivity modifier = 0.7
#[restriction school-closure]
#day-begins = 40
#day-ends = 100
#infectivity modifier =
# [5-9, 10-14, 15-19] : [5-9, 10-14, 15-19] : 0.5714
# all : [65-69, 70+] : 0.7143
#[restriction random-efforts]
#day-begins = 1
#day-ends = 180
#infectivity modifier = file://infectivity_modifier_matrix_example.csv
# Setup initial state
population_exposed = 0.005
population_infected = 0.005
probabilities = True
# Simulate up to 200 days
max_simulation_time = 200
method = 'DOP853'
max_step = 0.5
# https://www.rivm.nl/coronavirus-covid-19/ziekte:
## Als je besmet raakt duurt het meestal 5 tot 6 dagen voordat je klachten krijgt.
incubation_period = 5
# https://amazingerasmusmc.nl/biomedisch/hoelang-is-een-covid-19-patient-besmettelijk:
## We hebben aangetoond dat ernstig zieke covid-19-patienten tot zo’n vijftien dagen infectieus kunnen zijn.
## De meeste gegevens die tot nu toe werden gepubliceerd, zijn gebaseerd op metingen bij patiënten met milde klachten. Dan wordt uitgegaan van een dag of tien.
# https://www.gezondheidenwetenschap.be/gezondheid-in-de-media/wanneer-is-iemand-met-covid-19-het-meest-besmettelijk:
## In geen enkele studie konden onderzoekers nog levend virus aantonen 9 dagen na de start van de symptomen.
infectious_period = 9
initial_R0 = r['Rt_avg'][0]
print('initial_R0 = '+str(initial_R0))
hospitalization_probability = rivm_per_day['Hospital_admission_NICE'].sum()/rivm_per_day['Positive_tests'].sum()
print('hospitalization_probability until now = '+str(round(hospitalization_probability,4)))
icu_probability = rivm_per_day['IC_admission'].sum()/rivm_per_day['Positive_tests'].sum()
print('icu_probability = '+str(round(icu_probability,4)))
death_probability = rivm_per_day['Deceased_covid'].sum()/rivm_per_day['Positive_tests'].sum()
print('death_probability = '+str(round(death_probability,4)))
# https://www.rtlnieuws.nl/economie/artikel/5196644/corona-behandeling-kosten-testen-huisarts-intensive-care-totaal:
## Uit onderzoek van de Nederlandse Internisten Vereniging (NIV) komt naar voren dat een coronapatiënt gemiddeld zeven dagen op de verpleegafdeling ligt en/of dertien dagen op de intensive care.
hospitalization_duration = 7
icu_duration = 13
# https://wibnet.nl/geneeskunde/ziektes/van-dag-tot-dag-zo-neemt-het-coronavirus-je-lichaam-over:
## Na zeven dagen worden patiënten met ernstige klachten opgenomen in het ziekenhuis.
## Als de toestand verslechtert of als er nog meer organen uitvallen, wordt de patiënt na 10 dagen meestal opgenomen op de intensive care.
hospitalization_lag_from_onset = 7
icu_lag_from_onset = 10
# https://www.stichting-nice.nl/covid-19-op-de-ic.jsp:
## Verdeling overleden in ziekenhuis is vlakker dan levend uit ziekenhuis, doet gemiddelde verschuiven. standaard van model is 25 dagen. laat ik zo
death_lag_from_onset = 25
# Setup initial state
ni = 36
e = str(rivm_per_day.index[ni].year * 100 + rivm_per_day.index[ni].month)
e = e[:4] + '-' + e[-2:]
population_exposed = rivm_per_day.loc[rivm_per_day.index[ni],'Positive_tests'].sum() / population_per_month.loc[e,'Population']
population_infected = rivm_per_day.loc[rivm_per_day.index[ni],'prev_avg'].sum() / population_per_month.loc[e,'Population']
initial_R0 = 1.93 hospitalization_probability until now = 0.0292 icu_probability = 0.0055 death_probability = 0.007
run_model('show')
df = pd.DataFrame()
n=0
max_simulation_time = 60
for i in rivm_per_day.index:
try:
r['Rt_avg'][i]
except:
pass
else:
initial_R0 = r['Rt_avg'][i]
hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum()
icu_probability = rivm_per_day.loc[:i,'IC_admission'].sum()/rivm_per_day.loc[:i,'Positive_tests'].sum()
death_probability = rivm_per_day.loc[:i,'Deceased_covid'].sum()/rivm_per_day.loc[:i,'Positive_tests'].sum()
p = str(rivm_per_day.index[ni].year * 100 + rivm_per_day.index[ni].month)
p = e[:4] + '-' + e[-2:]
population = population_per_month.loc[p,'Population']
# Setup initial state
population_exposed = ( rivm_per_day.loc[i + pd.Timedelta(days=-7):i,'Positive_tests'].sum() / 7) / population
population_infected = ( rivm_per_day.loc[i + pd.Timedelta(days=-7):i,'prev_avg'].sum() / 7) / population
probabilities = True
run_model()
results['time'] = results[ 'time'].astype(int)
results['i'] = i
results['time'] = results.apply(lambda x: x['i'] + pd.Timedelta(days=x['time']), axis=1)
results['time'] = results['time'].astype(str)
n+=1
df = df.append(results)
df.reset_index(inplace=True, drop=True)
df
/tmp/ipykernel_29887/3497095173.py:11: RuntimeWarning: invalid value encountered in double_scalars hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /tmp/ipykernel_29887/3497095173.py:12: RuntimeWarning: invalid value encountered in double_scalars icu_probability = rivm_per_day.loc[:i,'IC_admission'].sum()/rivm_per_day.loc[:i,'Positive_tests'].sum() /tmp/ipykernel_29887/3497095173.py:13: RuntimeWarning: invalid value encountered in double_scalars death_probability = rivm_per_day.loc[:i,'Deceased_covid'].sum()/rivm_per_day.loc[:i,'Positive_tests'].sum() /tmp/ipykernel_29887/3497095173.py:11: RuntimeWarning: divide by zero encountered in double_scalars hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /home/cjvanzwol/miniconda3/envs/covid/lib/python3.9/site-packages/SEIR/seir.py:507: RuntimeWarning: invalid value encountered in multiply np.multiply(self.hospitalization_probability, np.divide(Ehl, self.incubation_period))
| time | (susceptible, All) | susceptible | (exposed, All) | exposed | (infected (active), All) | infected (active) | (infected (total), All) | infected (total) | (removed, All) | removed | (hospitalized (active), All) | hospitalized (active) | (in ICU, All) | in ICU | (deaths, All) | deaths | i | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2020-02-17 | 1.742410e+07 | 1.742410e+07 | 0.000000 | 0.000000 | 153.428571 | 153.428571 | 153.428571 | 153.428571 | 0.000000 | 0.000000 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 1 | 2020-02-18 | 1.742407e+07 | 1.742407e+07 | 28.372813 | 28.372813 | 140.162923 | 140.162923 | 156.265853 | 156.265853 | 16.244591 | 16.244591 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 2 | 2020-02-19 | 1.742404e+07 | 1.742404e+07 | 49.664394 | 49.664394 | 132.937719 | 132.937719 | 164.069573 | 164.069573 | 31.370085 | 31.370085 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 3 | 2020-02-20 | 1.742401e+07 | 1.742401e+07 | 66.146833 | 66.146833 | 130.009387 | 130.009387 | 175.650696 | 175.650696 | 45.944790 | 45.944790 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 4 | 2020-02-21 | 1.742399e+07 | 1.742399e+07 | 79.399175 | 79.399175 | 130.176979 | 130.176979 | 190.205297 | 190.205297 | 60.375267 | 60.375267 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 39115 | 2022-01-23 | 1.718872e+07 | 1.718872e+07 | 0.426478 | 0.426478 | 592.290659 | 592.290659 | 235626.443608 | 235626.443608 | 234949.094394 | 234949.094394 | 0.081087 | 0.081087 | 29.810434 | 29.810434 | 188.690834 | 188.690834 | 2021-11-29 |
| 39116 | 2022-01-24 | 1.718872e+07 | 1.718872e+07 | 0.349171 | 0.349171 | 530.078000 | 530.078000 | 235626.521173 | 235626.521173 | 235011.384360 | 235011.384360 | 0.066389 | 0.066389 | 26.827038 | 26.827038 | 188.775828 | 188.775828 | 2021-11-29 |
| 39117 | 2022-01-25 | 1.718872e+07 | 1.718872e+07 | 0.285877 | 0.285877 | 474.394429 | 474.394429 | 235626.584678 | 235626.584678 | 235067.131225 | 235067.131225 | 0.055227 | 0.055227 | 24.155482 | 24.155482 | 188.845415 | 188.845415 | 2021-11-29 |
| 39118 | 2022-01-26 | 1.718872e+07 | 1.718872e+07 | 0.234056 | 0.234056 | 424.555742 | 424.555742 | 235626.636671 | 235626.636671 | 235117.021733 | 235117.021733 | 0.046088 | 0.046088 | 21.763317 | 21.763317 | 188.902388 | 188.902388 | 2021-11-29 |
| 39119 | 2022-01-27 | 1.718872e+07 | 1.718872e+07 | 0.191629 | 0.191629 | 379.949250 | 379.949250 | 235626.679239 | 235626.679239 | 235161.670651 | 235161.670651 | 0.038606 | 0.038606 | 19.621442 | 19.621442 | 188.949033 | 188.949033 | 2021-11-29 |
39120 rows × 18 columns
#rcParams['figure.figsize'] = 20,100
#df.plot(subplots=True,kind='bar')
sns.relplot(
data=df,
x="time", y="susceptible",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33e4852730>
sns.relplot(
data=df,
x="time", y="exposed",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33d6eb4fd0>
rcParams['figure.figsize'] = 20,10
rivm_per_day[['Positive_tests','prev_avg']].plot()
<AxesSubplot:xlabel='Date'>
sns.relplot(
data=df,
x="time", y="infected (active)",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33d5e36610>
sns.relplot(
data=df,
x="time", y="infected (total)",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33d54cc040>
sns.relplot(
data=df,
x="time", y="removed",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33cfdfae20>
sns.relplot(
data=df,
x="time", y="exposed",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33cf490f40>
sns.relplot(
data=df,
x="time", y="hospitalized (active)",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33ce1d3910>
rivm_per_day[['Hospital_admission','Hospital_admission_NICE']].plot()
<AxesSubplot:xlabel='Date'>
sns.relplot(
data=df,
x="time", y="in ICU",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33ccf0d7f0>
rivm_per_day['IC_Bedden_COVID'].plot()
<AxesSubplot:xlabel='Date'>
sns.relplot(
data=df,
x="time", y="deaths",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33cbef76d0>
rivm_per_day['Deceased_covid'].plot()
<AxesSubplot:xlabel='Date'>
sns.set_theme(style="ticks")
for c in df.columns:
if c.__contains__('All') or c.__contains__('time') or c.__contains__('i'):
pass
else:
# Plot the lines on two facets
sns.relplot(
data=df,
x="time", y=c,
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
df2 = pd.DataFrame()
n=0
max_simulation_time = 60
for i in rivm_per_day.index:
try:
r['Rt_avg'][i]
except:
pass
else:
f = i + pd.Timedelta(days=-max_simulation_time)
initial_R0 = r['Rt_avg'][i]
hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum()
icu_probability = rivm_per_day['IC_admission'][f:i].sum()/rivm_per_day['Positive_tests'][:i].sum()
death_probability = rivm_per_day['Deceased_covid'][f:i].sum()/rivm_per_day['Positive_tests'][:i].sum()
p = str(rivm_per_day.index[ni].year * 100 + rivm_per_day.index[ni].month)
p = e[:4] + '-' + e[-2:]
population = population_per_month.loc[p,'Population']
# Setup initial state
population_exposed = rivm_per_day.loc[i + pd.Timedelta(days=-7):i,'Positive_tests'].sum() / population
population_infected = rivm_per_day.loc[i + pd.Timedelta(days=-7):i,'prev_avg'].sum() / population
probabilities = True
run_model()
results['time'] = results[ 'time'].astype(int)
results['i'] = i
results['time'] = results.apply(lambda x: x['i'] + pd.Timedelta(days=x['time']), axis=1)
results['time'] = results['time'].astype(str)
n+=1
df2 = df2.append(results)
df2.reset_index(inplace=True, drop=True)
df2
/tmp/ipykernel_29887/239506404.py:12: RuntimeWarning: invalid value encountered in double_scalars hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /tmp/ipykernel_29887/239506404.py:13: RuntimeWarning: invalid value encountered in double_scalars icu_probability = rivm_per_day['IC_admission'][f:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /tmp/ipykernel_29887/239506404.py:14: RuntimeWarning: invalid value encountered in double_scalars death_probability = rivm_per_day['Deceased_covid'][f:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /tmp/ipykernel_29887/239506404.py:12: RuntimeWarning: divide by zero encountered in double_scalars hospitalization_probability = rivm_per_day['Hospital_admission_NICE'][:i].sum()/rivm_per_day['Positive_tests'][:i].sum() /home/cjvanzwol/miniconda3/envs/covid/lib/python3.9/site-packages/SEIR/seir.py:507: RuntimeWarning: invalid value encountered in multiply np.multiply(self.hospitalization_probability, np.divide(Ehl, self.incubation_period))
| time | (susceptible, All) | susceptible | (exposed, All) | exposed | (infected (active), All) | infected (active) | (infected (total), All) | infected (total) | (removed, All) | removed | (hospitalized (active), All) | hospitalized (active) | (in ICU, All) | in ICU | (deaths, All) | deaths | i | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 2020-02-17 | 1.742318e+07 | 1.742318e+07 | 0.000000 | 0.000000 | 1074.000000 | 1074.000000 | 1.074000e+03 | 1.074000e+03 | 0.000000e+00 | 0.000000e+00 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 1 | 2020-02-18 | 1.742296e+07 | 1.742296e+07 | 198.598014 | 198.598014 | 981.139323 | 981.139323 | 1.093860e+03 | 1.093860e+03 | 1.137121e+02 | 1.137121e+02 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 2 | 2020-02-19 | 1.742276e+07 | 1.742276e+07 | 347.627948 | 347.627948 | 930.559724 | 930.559724 | 1.148482e+03 | 1.148482e+03 | 2.195903e+02 | 2.195903e+02 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 3 | 2020-02-20 | 1.742256e+07 | 1.742256e+07 | 462.993813 | 462.993813 | 910.056466 | 910.056466 | 1.229545e+03 | 1.229545e+03 | 3.216125e+02 | 3.216125e+02 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| 4 | 2020-02-21 | 1.742237e+07 | 1.742237e+07 | 555.748336 | 555.748336 | 911.223013 | 911.223013 | 1.331419e+03 | 1.331419e+03 | 4.226244e+02 | 4.226244e+02 | NaN | NaN | NaN | NaN | NaN | NaN | 2020-02-17 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 39115 | 2022-01-23 | 1.577546e+07 | 1.577546e+07 | 2.985346 | 2.985346 | 4146.034611 | 4146.034611 | 1.649385e+06 | 1.649385e+06 | 1.644644e+06 | 1.644644e+06 | 0.567611 | 0.567611 | 21.989349 | 21.989349 | 80.619522 | 80.619522 | 2021-11-29 |
| 39116 | 2022-01-24 | 1.577546e+07 | 1.577546e+07 | 2.444194 | 2.444194 | 3710.546002 | 3710.546002 | 1.649386e+06 | 1.649386e+06 | 1.645080e+06 | 1.645080e+06 | 0.464721 | 0.464721 | 19.788679 | 19.788679 | 80.655836 | 80.655836 | 2021-11-29 |
| 39117 | 2022-01-25 | 1.577546e+07 | 1.577546e+07 | 2.001137 | 2.001137 | 3320.761004 | 3320.761004 | 1.649386e+06 | 1.649386e+06 | 1.645470e+06 | 1.645470e+06 | 0.386586 | 0.386586 | 17.818034 | 17.818034 | 80.685567 | 80.685567 | 2021-11-29 |
| 39118 | 2022-01-26 | 1.577546e+07 | 1.577546e+07 | 1.638392 | 1.638392 | 2971.890191 | 2971.890191 | 1.649386e+06 | 1.649386e+06 | 1.645819e+06 | 1.645819e+06 | 0.322614 | 0.322614 | 16.053479 | 16.053479 | 80.709909 | 80.709909 | 2021-11-29 |
| 39119 | 2022-01-27 | 1.577546e+07 | 1.577546e+07 | 1.341402 | 1.341402 | 2659.644753 | 2659.644753 | 1.649387e+06 | 1.649387e+06 | 1.646132e+06 | 1.646132e+06 | 0.270239 | 0.270239 | 14.473548 | 14.473548 | 80.729839 | 80.729839 | 2021-11-29 |
39120 rows × 18 columns
for c in df.columns:
if c.__contains__('All') or c.__contains__('time') or c.__contains__('i'):
pass
else:
df[c].plot()
sns.relplot(
data=df2,
x="time", y="exposed",
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
<seaborn.axisgrid.FacetGrid at 0x7b33cb29f2b0>
for c in df2.columns:
if c.__contains__('All') or c.__contains__('time'):
pass
else:
# Plot the lines on two facets
sns.relplot(
data=df2,
x="time", y=c,
hue="i",
kind="line",
height=10, aspect=1.5,
facet_kws=dict(sharex=False),
legend=False
)
--------------------------------------------------------------------------- TypeError Traceback (most recent call last) /tmp/ipykernel_29887/2407878476.py in <module> 4 else: 5 # Plot the lines on two facets ----> 6 sns.relplot( 7 data=df2, 8 x="time", y=c, ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs) 44 ) 45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)}) ---> 46 return f(**kwargs) 47 return inner_f 48 ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/relational.py in relplot(x, y, hue, size, style, data, row, col, col_wrap, row_order, col_order, palette, hue_order, hue_norm, sizes, size_order, size_norm, markers, dashes, style_order, legend, kind, height, aspect, facet_kws, units, **kwargs) 1021 1022 # Draw the plot -> 1023 g.map_dataframe(func, **plot_kws) 1024 1025 # Label the axes ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/axisgrid.py in map_dataframe(self, func, *args, **kwargs) 748 749 # Draw the plot --> 750 self._facet_plot(func, ax, args, kwargs) 751 752 # Finalize the annotations and layout ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/axisgrid.py in _facet_plot(self, func, ax, plot_args, plot_kwargs) 773 plot_args = [] 774 plot_kwargs["ax"] = ax --> 775 func(*plot_args, **plot_kwargs) 776 777 # Sort out the supporting information ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/_decorators.py in inner_f(*args, **kwargs) 44 ) 45 kwargs.update({k: arg for k, arg in zip(sig.parameters, args)}) ---> 46 return f(**kwargs) 47 return inner_f 48 ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/relational.py in lineplot(x, y, hue, size, style, data, palette, hue_order, hue_norm, sizes, size_order, size_norm, dashes, markers, style_order, units, estimator, ci, n_boot, seed, sort, err_style, err_kws, legend, ax, **kwargs) 701 p._attach(ax) 702 --> 703 p.plot(ax, kwargs) 704 return ax 705 ~/miniconda3/envs/covid/lib/python3.9/site-packages/seaborn/relational.py in plot(self, ax, kws) 527 ax.plot(x[rows], y[rows], **kws) 528 else: --> 529 line, = ax.plot(x, y, **kws) 530 531 # --- Draw the confidence intervals ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/axes/_axes.py in plot(self, scalex, scaley, data, *args, **kwargs) 1605 lines = [*self._get_lines(*args, data=data, **kwargs)] 1606 for line in lines: -> 1607 self.add_line(line) 1608 self._request_autoscale_view(scalex=scalex, scaley=scaley) 1609 return lines ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/axes/_base.py in add_line(self, line) 2099 line.set_clip_path(self.patch) 2100 -> 2101 self._update_line_limits(line) 2102 if not line.get_label(): 2103 line.set_label('_line%d' % len(self.lines)) ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/axes/_base.py in _update_line_limits(self, line) 2121 Figures out the data limit of the given line, updating self.dataLim. 2122 """ -> 2123 path = line.get_path() 2124 if path.vertices.size == 0: 2125 return ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/lines.py in get_path(self) 1020 """ 1021 if self._invalidy or self._invalidx: -> 1022 self.recache() 1023 return self._path 1024 ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/lines.py in recache(self, always) 666 if always or self._invalidy: 667 yconv = self.convert_yunits(self._yorig) --> 668 y = _to_unmasked_float_array(yconv).ravel() 669 else: 670 y = self._y ~/miniconda3/envs/covid/lib/python3.9/site-packages/matplotlib/cbook/__init__.py in _to_unmasked_float_array(x) 1331 return np.ma.asarray(x, float).filled(np.nan) 1332 else: -> 1333 return np.asarray(x, float) 1334 1335 TypeError: float() argument must be a string or a number, not 'Period'
import epintervene